Declare.bas

The CygNet\Support\Declare.bas script file can be used to store a collection of global variables and scripted functions that are accessible to all CygNet Studio screens (.csf) in an application set. The Declare.bas is synonymous with the GlobalDeclarations section of a script. For example, the scripted functions in a Declare.bas might handle tasks such as: navigation through the screen hierarchy of a pipeline or field, retrieval of facility information, navigation of the facility hierarchy, history playback, scripted screen interfaces like modal dialog boxes and context menus, initialization of events, or scripted security checks for writing to communication devices.

While the variables and functions in a Declare.bas are accessible to all screens, they are not shared. For example, by declaring a variable "Bob" in the Declare.bas, so that you don’t have to declare that variable in each and every individual screen, the variable can be used by many screens. But each screen will have its own completely independent "Bob" variable. Sharing data between screens is accomplished using script such as the Dictionary object and Custom Events.

The Declare.bas is loaded at the time the screen is loaded, so if changes are made to it, they will take effect the next time a screen is (re)opened. The file is also saved when you exit the script editor, which is important to note so you don’t lose work. For example, if you are editing two screens at the same time, and you edit the global declarations in one, save it, then save the second screen, you will lose your changes to the global declarations.

Managing the Declare.bas File

Before making modifications to the Declare.bas file, make sure you have the correct version of the file on your computer. The Declare.bas file is incorporated into the version management process, so running CygNet Studio from the Start\All Programs\CygNet\ group will download the version-managed version of the file to the CygNet\Support directory. Although it is unlikely, always check to ensure that the file CygNet\Support\Declare.bas does not have the “read-only” flag set.

Once you start modifying the Declare.bas file, do not launch any CygNet Client application from a version-managed shortcut (for example, Start\Programs\CygNet\…) since that process could over-write the local, modified copy of Declare.bas with the older version from the APPS service, resulting in updates being lost. When you are done making and testing your changes, you must update the version of Declare.bas in the APPS with the new version on your computer directly using CygNet Explorer or BSS Explorer. The Declare.bas file is not automatically saved to the APPS when you save your changes from within CygNet Studio.

Option Explicit in Declare.bas

It is recommended that you use the Option Explicit statement in all CygNet Studio scripts to force explicit declaration of all variables in a file. This statement can also help expose uninitialized variable errors in your scripts. VBScript requires that Option Explicit be the first statement in a script. Using Option Explicit in a screen script requires putting it at the top of the Declarations section.

CygNet Studio allows the Option Explicit statement in either or both the Declare.bas file and in a screen script. Studio combines the Declare.bas file and the screen script by appending the screen’s script to the end of the Declare.bas file. Regardless of the location of the Option Explicit statement the screen will load and Option Explicit is enabled.

For more information about using Option Explicit in HyperPoint scripts, see Using Option Explicit in HyperPoint Scripts.